home *** CD-ROM | disk | FTP | other *** search
/ A.C.E. 2 / ACE CD 2.iso / FILES / UTILS / AMOSPRO4.DMS / in.adf / Tutorials / Menus / Menus_1.AMOS / Menus_1.amosSourceCode
Encoding:
AMOS Source Code  |  1992-09-28  |  3.7 KB  |  129 lines

  1. '*************************** 
  2. '*    AMOS Professional    * 
  3. '*                         * 
  4. '*         MENUS 1         * 
  5. '*                         *       Creating and reading a simple menu
  6. '* (c) Europress Software  * 
  7. '*                         * 
  8. '*     Ronnie Simpson      * 
  9. '*************************** 
  10. '
  11. '------------------------------------------- 
  12. 'SETTING UP
  13. '------------------------------------------- 
  14. 'The initial stage in creating a menu is to set out the title headings:- 
  15. '
  16. '
  17. '              Menu$(1)="SYSTEM  " 
  18. '              Menu$(2)="BRUSHES  "
  19. '              Menu$(3)="COLOURS"
  20. '
  21. 'Titles are generated from left to right and spaces should be included in
  22. 'the strings to separate the titles along the bar. 
  23. '
  24. 'The next thing we need is the options to be added:- 
  25. '
  26. '              Menu$(1,1)="LOAD" 
  27. '              Menu$(1,2)="SAVE" 
  28. '              Menu$(1,3)="QUIT" 
  29. '              Menu$(3,1)="RED"
  30. '
  31. 'Options are listed from top to bottom and there are no restrictions to the
  32. 'number of options each title can have.
  33. '
  34. 'When all your titles and options have been set out the menu must be switched  
  35. 'on with the simple instruction:-
  36. '
  37. '              Menu On 
  38. '
  39. 'Your set of titles will now appear each time the right mouse key is held
  40. 'down. 
  41. '
  42. '------------------------------------------- 
  43. 'READING A MENU
  44. '------------------------------------------- 
  45. 'The simplest way of reading the menu is by use of the 3 versions of 
  46. 'the =Choice function
  47. '------- 
  48. '1) The first thing we need to know is whether the menu has been highlighted 
  49. '    by the user, this is achieved by using =Choice without any parameters.
  50. '    A value of -1 (or True) will be returned if the menu is highlighted or
  51. '    a value of 0 (or False)will be returned if it is not. 
  52. '
  53. '              If Choice=-1 Then Print "MENU ACTIVE" 
  54. '      If Choice=-1 may be shortened to:-   If choice then.....  
  55. '
  56. '
  57. '2) To find the title that has been selected =Choice(1) is used:-  
  58. '
  59. '              TITLE=Choice(1) 
  60. '
  61. 'Choice(1) returns the index number of the title selected by the user. 
  62. '
  63. '
  64. '3) And finally =Choice(2) is used to find the option selected.:-  
  65. '
  66. '              OPTION=Choice(2)
  67. '
  68. 'Choice(2) returns the index number of the option selected by the user.  
  69. '
  70. '------------------------------------------- 
  71. 'WORKING EXAMPLE 
  72. '------------------------------------------- 
  73. '
  74. Rem *** tidy up the screen 
  75. '
  76. Palette $0,$F00,$F0,$F,$FF0,$F0F,$FF,$F70,$7F,$70F,$F07,$333,$666,$999,$FFA,$FFF
  77. Flash Off : Curs Off : Cls 0 : Pen 0 : Paper 14 : Ink 4,0
  78. '
  79. Rem *** set the menu titles
  80. '
  81. Menu$(1)=" System    "
  82. Menu$(2)=" Text Style   "
  83. Menu$(3)=" Text Colours "
  84. '
  85. Rem *** set the options
  86. '
  87. Menu$(1,1)=" Edit   "
  88. Menu$(1,2)=" Stop   "
  89. Menu$(1,3)=" Quit   "
  90. '
  91. Menu$(2,1)=" Normal                    "
  92. Menu$(2,2)=" Underline                 "
  93. Menu$(2,3)=" Bold                      "
  94. Menu$(2,4)=" Bold+underline            "
  95. Menu$(2,5)=" Italic                    "
  96. Menu$(2,6)=" Italic +Underline         "
  97. Menu$(2,7)=" Bold + Italic             "
  98. Menu$(2,8)=" Bold + Italic + Underline "
  99. '
  100. Menu$(3,1)=" Red        "
  101. Menu$(3,2)=" Green      "
  102. Menu$(3,3)=" Blue       "
  103. Menu$(3,4)=" Yellow     "
  104. Menu$(3,5)=" Magenta    "
  105. Menu$(3,6)=" Cyan       "
  106. '
  107. Rem *** start the main loop and read the menu
  108. '
  109. Do 
  110.    Locate 0,20 : Cline : Centre "PRESS RIGHT MOUSE KEY TO SEE MENU"
  111.    Repeat : Until Mouse Key=2
  112.    Cline : Centre "MENU SYSTEM ACTIVATED"
  113.    Menu On : T=0 : P=0
  114.    Wait Vbl 
  115.    While Choice : Wend 
  116.    T=Choice(1)
  117.    P=Choice(2)
  118.    Menu Off 
  119.    If Choice(1)=2 Then Set Text P-1
  120.    If Choice(1)=3 Then Ink P,0
  121.    If Choice(1)=1 Then Edit 
  122.    If Not O Then Cls 0 : Text 66,100,"NO OPTION WAS SELECTED"
  123.    If T
  124.       Cls 0
  125.       Text 50,40,"YOU SELECTED TITLE NUMBER"+Str$(T)
  126.       Text 46,70,"YOU SELECTED OPTION NUMBER"+Str$(P)
  127.    End If 
  128. Loop 
  129. Wait Key